<?php
/**
 * cookies加密函数
 * @param string 加密后字符串
 */
function encrypt($data, $key = 'kls8in1e') {
    $prep_code = serialize($data);
    $encrypt = openssl_encrypt($prep_code,'des',$key, OPENSSL_RAW_DATA,$key);
    return base64_encode($encrypt);
}

/**
 * cookies 解密密函数
 * @param array 解密后数组
 */
function decrypt($str, $key = 'kls8in1e') {
    $str = openssl_decrypt(base64_decode($str),'des',$key, OPENSSL_RAW_DATA,$key);
    return unserialize($str);
}




?>